
using System;
using System.Collections;
using System.Web.UI.WebControls;

namespace GiftNet.Model
{
	#region ProOrderHis Model -(by fangyifeng at 2007-09-14 12:24:21)

	/// <summary>
	/// ProOrderHis object'ProOrderHis'.
	/// </summary>
	[Serializable]
	public class ProOrderHis : System.IComparable
		{
		#region Member Variables
		
		protected Guid _id;
		protected double _quantity;
        protected string _size;
        protected string _colour;
		protected double _price;
		protected string _indivReq;
		protected string _indivPackReq;
		protected string _indivID;
		protected string _indivName;
		protected double _indivPrice;
		protected string _indivPackID;
		protected string _indivPackName;
		protected double _indivPackPrice;
		protected Guid _storageId;
		protected ProductOrderHis _ProductOrderHis;
		protected FileInfo _fileInfo;
		protected Product _product;
		
		protected static String _sortExpression = "Id";
		protected static SortDirection _sortDirection = SortDirection.Ascending;

		#endregion

		#region Constructors

		public ProOrderHis() { }

        public ProOrderHis(double quantity, double price, string indivReq, string indivPackReq, string indivID, string indivName, double indivPrice, string indivPackID, string indivPackName, double indivPackPrice, Guid storageId, ProductOrderHis ProductOrderHis, FileInfo fileInfo, Product product)
		{
			this._quantity = quantity;
			this._price = price;
			this._indivReq = indivReq;
			this._indivPackReq = indivPackReq;
			this._indivID = indivID;
			this._indivName = indivName;
			this._indivPrice = indivPrice;
			this._indivPackID = indivPackID;
			this._indivPackName = indivPackName;
			this._indivPackPrice = indivPackPrice;
			this._storageId = storageId;
			this._ProductOrderHis = ProductOrderHis;
			this._fileInfo = fileInfo;
			this._product = product;
		}

		#endregion

		#region Public Properties

        public virtual string Size
        {
            get
            {
                if (_size != null)
                    return _size;
                else
                    return String.Empty;
            }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for _size", value, value.ToString());
                _size = value;
            }
        }


        public virtual string Colour
        {
            get
            {
                if (this._colour != null)
                    return _colour;
                else
                    return String.Empty;
            }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for _size", value, value.ToString());
                _colour = value;
            }
        }

		public virtual Guid Id
		{
			get {return _id;}
			set {_id = value;}
		}

		public virtual double Quantity
		{
			get { return _quantity; }
			set { _quantity = value; }
		}

		public virtual double Price
		{
			get { return _price; }
			set { _price = value; }
		}

		public virtual string IndivReq
		{
			get { return _indivReq; }
			set
			{
				if ( value != null && value.Length > 400)
					throw new ArgumentOutOfRangeException("Invalid value for IndivReq", value, value.ToString());
				_indivReq = value;
			}
		}

		public virtual string IndivPackReq
		{
			get { return _indivPackReq; }
			set
			{
				if ( value != null && value.Length > 400)
					throw new ArgumentOutOfRangeException("Invalid value for IndivPackReq", value, value.ToString());
				_indivPackReq = value;
			}
		}

		public virtual string IndivID
		{
			get { return _indivID; }
			set
			{
				if ( value != null && value.Length > 64)
					throw new ArgumentOutOfRangeException("Invalid value for IndivID", value, value.ToString());
				_indivID = value;
			}
		}

		public virtual string IndivName
		{
			get { return _indivName; }
			set
			{
				if ( value != null && value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for IndivName", value, value.ToString());
				_indivName = value;
			}
		}

		public virtual double IndivPrice
		{
			get { return _indivPrice; }
			set { _indivPrice = value; }
		}

		public virtual string IndivPackID
		{
			get { return _indivPackID; }
			set
			{
				if ( value != null && value.Length > 64)
					throw new ArgumentOutOfRangeException("Invalid value for IndivPackID", value, value.ToString());
				_indivPackID = value;
			}
		}

		public virtual string IndivPackName
		{
			get { return _indivPackName; }
			set
			{
				if ( value != null && value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for IndivPackName", value, value.ToString());
				_indivPackName = value;
			}
		}

		public virtual double IndivPackPrice
		{
			get { return _indivPackPrice; }
			set { _indivPackPrice = value; }
		}

		public virtual Guid StorageId
		{
			get { return _storageId; }
			set { _storageId = value; }
		}

		public virtual ProductOrderHis ProductOrderHis
		{
			get { return _ProductOrderHis; }
			set { _ProductOrderHis = value; }
		}

		
		public virtual FileInfo FileInfo
		{
			get { return _fileInfo; }
			set { _fileInfo = value; }
		}

		
		public virtual Product Product
		{
			get { return _product; }
			set { _product = value; }
		}

		
        public static String SortExpression
        {
            get { return _sortExpression; }
            set { _sortExpression = value; }
        }

        public static SortDirection SortDirection
        {
            get { return _sortDirection; }
            set { _sortDirection = value; }
        }
		#endregion
		
        #region IComparable Methods
        public virtual int CompareTo(object obj)
        {
			if (!(obj is ProOrder))
				throw new InvalidCastException("This object is not of type ProOrder");
			
			int relativeValue;
			switch (SortExpression)
			{
				case "Id":
					relativeValue = this.Id.CompareTo(((ProOrder)obj).Id);
					break;
				case "Quantity":
					relativeValue = this.Quantity.CompareTo(((ProOrder)obj).Quantity);
					break;
				case "Price":
					relativeValue = this.Price.CompareTo(((ProOrder)obj).Price);
					break;
				case "IndivReq":
					relativeValue = (this.IndivReq != null) ? this.IndivReq.CompareTo(((ProOrder)obj).IndivReq) : -1;
					break;
				case "IndivPackReq":
					relativeValue = (this.IndivPackReq != null) ? this.IndivPackReq.CompareTo(((ProOrder)obj).IndivPackReq) : -1;
					break;
				case "IndivID":
					relativeValue = (this.IndivID != null) ? this.IndivID.CompareTo(((ProOrder)obj).IndivID) : -1;
					break;
				case "IndivName":
					relativeValue = (this.IndivName != null) ? this.IndivName.CompareTo(((ProOrder)obj).IndivName) : -1;
					break;
				case "IndivPrice":
					relativeValue = (this.IndivPrice != null) ? this.IndivPrice.CompareTo(((ProOrder)obj).IndivPrice) : -1;
					break;
				case "IndivPackID":
					relativeValue = (this.IndivPackID != null) ? this.IndivPackID.CompareTo(((ProOrder)obj).IndivPackID) : -1;
					break;
				case "IndivPackName":
					relativeValue = (this.IndivPackName != null) ? this.IndivPackName.CompareTo(((ProOrder)obj).IndivPackName) : -1;
					break;
				case "IndivPackPrice":
					relativeValue = (this.IndivPackPrice != null) ? this.IndivPackPrice.CompareTo(((ProOrder)obj).IndivPackPrice) : -1;
					break;
				case "StorageId":
					relativeValue = (this.StorageId != null) ? this.StorageId.CompareTo(((ProOrder)obj).StorageId) : -1;
					break;
                default:
                    goto case "Id";
			}
            if (ProOrder.SortDirection == SortDirection.Ascending)
				relativeValue *= -1;
			return relativeValue;
		}
		#endregion
	}

	#endregion
}
